<?php
/**
 * Created by PhpStorm.
 * User: chendan
 * Date: 2017/2/21
 * Time: 下午9:34
 */
$myarray = array('one', 'two', 'three');
$myobj = (object)$myarray;

if (!($myarray instanceof \Traversable)) {
    print "myarray is NOT Traversable";
}

if (!($myobj instanceof \Traversable)) {
    print "myobj is NOT Traversable";
}

foreach ($myarray as $value) {
    print $value;
}
foreach ($myobj as $value) {
    print $value;
}

//Output:
//myarray is NOT Traversable
//myobj is NOT Traversable
//one
//two
//three
//one
//two
//three

